package com.atguigu.gmall.fastdfs;

import org.csource.common.MyException;
import org.csource.fastdfs.*;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ClassUtils;

import java.io.IOException;

/**
 * @Author: lx
 * @Time: 11:38
 * @Description:
 */
public class FastDFSDemo {

    public static void main(String[] args) throws IOException, MyException {
        //1:上传图片
        //2:连接Tracker    192.168.200.130:22122
        //流 只认识绝对路径  不认识相对路径
        String path = ClassUtils.getDefaultClassLoader().
                getResource("fdfs_client.conf").getPath();
        ClientGlobal.init(path);
        TrackerClient trackerClient = new TrackerClient();
        //连接Tracker
        TrackerServer trackerServer = trackerClient.getConnection();
        StorageServer storageServer = null;
        //连接上了存储节点
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,storageServer);
        //上传图片
        String p = storageClient1.upload_file1("D:\\尚品汇商城\\资料\\图片\\Apple11\\5f7eafcd01dd2304.jpg",
                "jpg", null);
        System.out.println(p);// 2 连接不上storage  28 磁盘使用空间所剩不多 90%

    }
}
